/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package logic.services;

import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;
import edu.fca.beans.AlumnoBean;
import edu.fca.daos.AlumnoDAO;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Romms
 */
public class AlumnoServices {

    private static AlumnoDAO alumnoDAO = new AlumnoDAO();
    private static AlumnoServices instance;

    private AlumnoServices(){
        
    }

    public static AlumnoServices getInstance(){
        if(instance==null){
            instance=new AlumnoServices();
        }
        return instance;
    }

    public void addAlumno(AlumnoBean alumnoBean) throws MySQLIntegrityConstraintViolationException{
        try {
            alumnoDAO.add(alumnoBean);
        }catch (MySQLIntegrityConstraintViolationException ex) {
            throw ex;
        } catch (Exception ex) {
            Logger.getLogger(AlumnoServices.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public ArrayList<AlumnoBean> getAlumnos(){
        try {
            return alumnoDAO.selectAll();
        } catch (Exception ex) {
            Logger.getLogger(AlumnoServices.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

}
